<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
    <!--<link rel="stylesheet" href="/static/admin/voucher.css">-->
    <link rel="stylesheet" type="text/css" href="/static/taginput/css/normalize.css" /><!--CSS RESET-->
    <link rel="stylesheet" href="/static/taginput/src/jquery.tagsinput-revisited.css" />
    <style>
        .layui-form-select .layui-input{
            width:400px;
        }
    </style>
    <style>
        .standard-div{
            display: flex;
            flex-wrap: wrap;
        }
        .standard-div button{
            width:90px;
            position: relative;
            margin-left: 10px;
            margin-top: 10px;
            height: 37px;
        }
        .standard-value{
            width:110px;
            position: relative;
            margin-left: 10px;
            margin-top: 10px;
        }
        .standard-div .standard-value i{
            position: absolute;
            top: -1px;
            right: -5px;
        }
    </style>
    <!--<link rel="stylesheet" href="/static/layuimini/lib/jq-module/zyupload/zyupload-1.0.0.min.css" media="all">-->
</head>
<body>
<div style="padding-top:10px;" class="layui-form layuimini-form">
    <input type="hidden" name="id" value="{$id}">
    <div class="layui-form-item">
        <label class="layui-form-label required">商品名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="商品名称不能为空" placeholder="请输入商品名称" value="{$bizpro.name}" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text " id="showContext">
        <label class="layui-form-label required">商品分类</label>
        <div class="layui-input-inline ">
            <select name="class_id" lay-filter="selectInfo">
                <option value=""></option>
                {volist name="class" id="v"}
                <option value="{$v.id}" {if condition="$bizpro.class_id == $v.id"}selected{/if}>{$v.title}</option>
                {/volist}
            </select>
        </div>

    </div>
    <div class="layui-form-item layui-form-text " id="showContext">
        <label class="layui-form-label required">展示专区</label>
        <div class="layui-input-inline ">
            <select name="class_id" lay-filter="selectInfo">
                <option value=""></option>
                {volist name="spearea" id="vs"}
                <option value="{$vs.id}" {if condition="$bizpro.spearea_id == $vs.id"}selected{/if}>{$vs.title}</option>
                {/volist}
            </select>
        </div>

    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">商品货号</label>
        <div class="layui-input-block">
            <input type="text" name="bizpro_number"  lay-verify="required"  value="{$bizpro.bizpro_number}" placeholder="请输入商品货号" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    {if condition="$id"}
    <div class="layui-form-item layui-form-text" id="bizstandard"  style="display:block;">
        <div style="margin-left: 149px">
            <div id="standard"  >
                {volist name="standard" id="v"}
                <div   style='float: left;width:100px;height:50px; background: aliceblue;'
                       onclick='bizStandardDel("DB","{$v.title}","{$v.id}")'><button>{$v.title}</button>
                </div>
                {/volist}
            </div>
        </div>


    </div>
    {else/}
    <div class="layui-form-item layui-form-text" id="bizstandard"  style="display:none;">
        <div style="margin-left: 149px">
            <div id="standard"  >

            </div>
        </div>


    </div>
    {/if}
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">商品单位</label>
        <div class="layui-input-block">
            <input type="text" name="bizpro_unit"  lay-verify="required"  value="{$bizpro.bizpro_unit}" placeholder="请输入商品单位" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text" id="">
        <label class="layui-form-label required">关联供应商</label>
        <div class="layui-input-inline">
            <select name="supplier_id" lay-filter="selectInfo">
                <option value=""></option>
                {volist name="supplier" id="v"}
                <option value="{$v.id}" {if condition="$bizpro.class_id == $v.id"}selected{/if}>{$v.supplier_name}</option>
                {/volist}
            </select>
        </div>

    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">售价</label>
        <div class="layui-input-block">
            <input type="number" name="sale_price" min="1" step="0.01" lay-verify="required" placeholder="请输入商品售价" value="{$bizpro.sale_price}" class="layui-input iwidth" >
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">原价</label>
        <div class="layui-input-block">
            <input type="number" name="old_price" min="1" step="0.01" lay-verify="required" placeholder="请输入商品原价"  value="{$bizpro.old_price}" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">进价</label>
        <div class="layui-input-block">
            <input type="number" name="pursh_price" min="1" step="0.01" lay-verify="required"placeholder="请输入商品进价"  value="{$bizpro.pursh_price}" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">虚拟数量</label>
        <div class="layui-input-block">
            <input type="number" name="fake_num" min="1" lay-verify=""  value="{$bizpro.fake_num}" placeholder="请输入商品虚拟数量" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">标签</label>
        <div class="layui-input-block">
            <input type="text" id="form-tags-1" name="label" lay-verify=""  value="{$bizpro.label}" class="layui-input iwidth" autocomplete="off">
        </div>
    </div>

    <!--参数-->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">商品参数</label>
        <div class="layui-btn-container">
            <button class="layui-btn "  id="add-params">新增参数</button>
        </div>
    </div>
    <table class="layui-table" style="width:80%;margin-left: 150px;">
        <colgroup>
            <col width="150">
            <col width="200">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>名称</th>
            <th>答案</th>
            <th>签名</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>参数1</td>
            <td>2016-11-29</td>
            <td>
                <button type="button" class="layui-btn layui-btn-sm">编辑</button>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-danger">删除</button>
            </td>
        </tr>

        </tbody>
    </table>

    {if condition="$id"}
    <!--商品规格名称    -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">商品规格</label>
    </div>
    <table class="layui-table" id="standard-base"   style="width:80%;margin-left: 150px;">
        <colgroup>
            <col width="150">
            <col >
        </colgroup>
        <thead>
        <tr>
            <th>备注名</th>
            <th>名称</th>
            <th>规格值</th>
        </tr>
        </thead>
        <tbody>
        {volist name="standard_base" id="vo" key="k" }
        <tr>
            <td>规格{$k}</td>
            <td> <input type="text" name="standard_base_name1" placeholder="规格名称"    value="{$vo.name}" style="width:100px"  class="layui-input " autocomplete="off"></td>
            <td>
                <div class="standard-div" data-name="1">
                    {volist name="$vo.value" id="vv" key="kk" }
                    <div class="standard-value">
                        <input type="text" name="standard_base_value1[]"   value="{$vv}" style="width:100px"  class="layui-input iwidth" autocomplete="off">
                        <i class="fa fa-close"  ></i>
                    </div>
                    {/volist}
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-sm">添加</button>
                </div>

            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <!--商品规格价格    -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">规格价格</label>
        <div class="layui-btn-container">
            <button class="layui-btn "  id="add-standard-price">新增规格价格</button>
        </div>
    </div>
    <table class="layui-table" style="width:80%;margin-left: 150px;" id="standard-price">
        <colgroup>
            <col width="150">
            <col width="200">
            <col width="200">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>规格1</th>
            <th>规格2<!--<i class="fa fa-close" style="float: right"></i>--></th>
            <td>售卖价格</td>
            <td>进货价格</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        {volist name="standard_price_arr" id="vspa" key="kspa" }
        <tr>
            <td><input type="text"  name="standard_price_name1[]"  value="{$vspa.standard_value1}"    class="layui-input  " autocomplete="off"></td>
            <td><input type="text"  name="standard_price_name2[]"  value="{$vspa.standard_value2}"    class="layui-input  " autocomplete="off"></td>
            <td><input type="text"    value="{$vspa.buy_price}"   name="buy_price[]" class="layui-input  " autocomplete="off"></td>
            <td><input type="text"    value="{$vspa.sale_price}"  name="sale_price[]"  class="layui-input  " autocomplete="off"></td>
            <td>
                {if condition="$kspa>1"}
                <button type="button" onclick="deltr(this)" class="layui-btn">删除</button>
                {/if}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    {else}
    <!--商品规格名称    -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">商品规格</label>
    </div>
    <table class="layui-table" id="standard-base"   style="width:80%;margin-left: 150px;">
        <colgroup>
            <col width="150">
            <col >
        </colgroup>
        <thead>
        <tr>
            <th>备注名</th>
            <th>名称</th>
            <th>规格值</th>
        </tr>
        </thead>
        <tbody>

        <tr>
            <td>规格1</td>
            <td> <input type="text" name="standard_base_name1" placeholder="规格名称"    value="" style="width:100px"  class="layui-input " autocomplete="off"></td>
            <td>
                <div class="standard-div" data-name="1">
                    <div class="standard-value">
                        <input type="text" name="standard_base_value1[]"   value="" style="width:100px"  class="layui-input iwidth" autocomplete="off">
                        <i class="fa fa-close"  ></i>
                    </div>
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-sm">添加</button>
                </div>

            </td>
        </tr>
        <tr>
            <td>规格2</td>
            <td> <input type="text" name="standard_base_name2" placeholder="规格名称"    value="" style="width:100px"  class="layui-input " autocomplete="off"></td>
            <td>
                <div class="standard-div" data-name="2">
                    <div class="standard-value">
                        <input type="text" name="standard_base_value2[]"   value="" style="width:100px"  class="layui-input iwidth" autocomplete="off">
                        <i class="fa fa-close"  ></i>
                    </div>
                    <button type="button" class="layui-btn layui-btn-primary layui-btn-sm">添加</button>
                </div>

            </td>
        </tr>
        </tbody>
    </table>
    <!--商品规格价格    -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">规格价格</label>
        <div class="layui-btn-container">
            <button class="layui-btn "  id="add-standard-price">新增规格价格</button>
        </div>
    </div>
    <table class="layui-table" style="width:80%;margin-left: 150px;" id="standard-price">
        <colgroup>
            <col width="150">
            <col width="200">
            <col width="200">
            <col width="200">
        </colgroup>
        <thead>
        <tr>
            <th>规格1<i class="fa fa-close" style="float: right"></i></th>
            <th>规格2<i class="fa fa-close" style="float: right"></i></th>
            <td>售卖价格</td>
            <td>进货价格</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>

        <tr>
            <td><input type="text"  name="standard_price_name1[]"  value=""    class="layui-input  " autocomplete="off"></td>
            <td><input type="text"  name="standard_price_name2[]"  value=""    class="layui-input  " autocomplete="off"></td>
            <td><input type="text"    value=""   name="buy_price[]" class="layui-input  " autocomplete="off"></td>
            <td><input type="text"    value=""  name="sale_price[]"  class="layui-input  " autocomplete="off"></td>
            <td></td>
        </tr>

        </tbody>
    </table>
    {/if}

    <div class="layui-form-item">
        <label class="layui-form-label">缩略图上传</label>
        <input type="hidden" id="imgurlHidden" name="imgurl" value="">
        <div class="layui-input-inline uploadHeadImage">
            <div class="layui-upload-drag" id="headImg">
                <i class="layui-icon"></i>
                <p>点击上传图片，或将图片拖拽到此处</p>
            </div>
        </div>
        <div class="layui-input-inline">
            <div class="layui-upload-list" style="margin-top: 5px;">
                {if condition="$bizpro.id"}
                <input type="hidden" id="oldimgurlHidden" name="old_imgurl" value="{$bizpro.imgurl}">
                <img class="layui-upload-img headImage" style="height: 100px;" id="imgurl" src="/upload/{$bizpro.imgurl}" >
                {else/}
                <img class="layui-upload-img headImage" style="height: 100px;" id="imgurl" >
                {/if}
                <p id="demoText"></p>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">banner上传</label>
        <input type="hidden" id="banner_images" name="banner" value="{$bizpro.banner}">
        <div class="layui-upload">
            <div class="layui-form-mid layui-word-aux">
                <button type="button" class="layui-btn" id="multiple_banner">多图片上传</button>
                <span class="x-red">*</span>为保证图片质量，轮播图片请尽量选择200*200的方形图片,图片大小不要超过500KB,一般在30KB-100KB之间
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                    预览：
                    <div class="layui-upload-list" id="div-slide_show">
                        {volist name="$bannerArr" id='ba'}
                        <img src="/upload/{$ba}" alt="{$ba}" title="点击删除" style="width: 100px;height: 100px" class="layui-upload-img" onclick="delMultipleImgs(this,'banner')">
                        {/volist}
                    </div>
                </blockquote>
            </div>
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">参数</label>
        <div class="layui-input-block">
            <textarea type="text" name="param" value="" lay-verify="param" autocomplete="off" placeholder="描述内容" class="layui-input" aria-disabled="true" style="margin: 0px 10.125px 0px 0px;width: 1558px;height: 152px;">{$bizpro.param}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">详情上传</label>
        <div class="layui-input-block">
            <div class="layui-textarea" id='LAY_demo_editor' ></div>
            <input type="hidden" id="editorimgurlHidden"  name="detail" value="" >
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>


</div>
{include file="public/footer" /}
<script src="/static/taginput/src/jquery.tagsinput-revisited.js"></script>
<!--<script src="/static/layuimini/lib/jq-module/zyupload/zyupload-1.0.0.min.js" charset="utf-8"></script>-->

<script>
    // 进入页面执行的方法


    let banner_url=[{$bannerurl}];

    $(function() {
        $('#form-tags-1').tagsInput({
            'delimiter': ',',
            placeholder: '添加标签,回车键添加下一个',
        });
    });
    layui.use(['form','wangEditor','laydate','upload'], function () {
        let form = layui.form,
            layer = layui.layer,
            wangEditor = layui.wangEditor,
            upload = layui.upload,
            laydate=layui.laydate,
            $ = layui.$;
        /*添加参数值*/

        /*删除参数值*/
        $(".standard-value .fa-close").on('click', function(re){
            $(this).parents(".standard-value").remove()
        })
        /*删除规格值 */
        $(".standard-value .fa-close").on('click', function(re){
            $(this).parents(".standard-value").remove()
        })
        /*添加规格值 */
        $(".standard-div button").on('click', function(re){
            let index=$(this).parents('.standard-div').attr('data-name')
            let aa=$(this).parents('.standard-div').html()
            console.log($(this).parents('.standard-div').attr('data-name'))

            let input_html=' <div class="standard-value">\n' +
                '                    <input type="text" name="standard_base_value'+index+'[]"   value="" style="width:100px"  class="layui-input iwidth" autocomplete="off">\n' +
                '                    <i class="fa fa-close"  ></i>\n' +
                '                </div>'
            $(this).before(input_html);

        })


        /*添加规格价格*/
        $("#add-standard-price").on('click', function(){
            let tr = $("#standard-price tr:last");
            let aa='<tr>\n' +
                '            <td><input type="text"  name="standard_price_name1[]"  value=""    class="layui-input  " autocomplete="off"></td>\n' +
                '            <td><input type="text"  name="standard_price_name2[]"  value=""    class="layui-input  " autocomplete="off"></td>\n' +
                '            <td><input type="text"    value="0"   name="buy_price[]" class="layui-input  " autocomplete="off"></td>\n' +
                '            <td><input type="text"    value="0"  name="sale_price[]"  class="layui-input  " autocomplete="off"></td>\n' +
                '            <td><button type="button" onclick="deltr(this)" class="layui-btn">删除</button></td>\n' +
                '        </tr>'
            if(tr.length==0){
                layer.alert("指定的table或对应的行数不存在！");
                return;
            }
            tr.after(aa);
            return false
            /*判断按钮*/
            if($("#add-standard-price").attr('class')=='layui-btn layui-btn-primary')
            {
                layer.alert('规格类型达到上限')
                return false
            }

            //判断规格名和规格价格长度是否对应
            let standard_base_name=$("#standard-base tbody tr input[name='standard_base_name[]']")
            let standard_price_name=$("#standard-price tbody tr input[name=\"standard_price_name[]\"]")
            //规格名长度
            let standard_name=0
            let standard_price=0

            standard_base_name.each(function (index,re) {
                if($(re).val()=='')
                {
                    return true
                }
                standard_name+=1
            })
            standard_price_name.each(function (index,re) {
                if($(re).val()=='')
                {
                    return true
                }
                standard_price+=1
            })
            if(standard_price==standard_name)
            {
                layer.alert('规格类型达到上限')
                return false
            }

            //添加列
            let col=''
            let th=''
            let td=''
            standard_base_name.each(function (index,re) {
                if($(re).val()=='')
                {
                    return true
                }
                col = $("<col width=\"200\">");
                th = $("<td name='Myname'>"+$(re).val()+"<i class='fa fa-close' onclick='delCol(this)'  style='float: right'></i></td>");
                td = $("<td><input type=\"text\"  name=\"standard_price_name[]\"  value=\"0\"    class=\"layui-input  \" autocomplete=\"off\"></td>");
                $("#standard-price>colgroup>tr").append(col);
                $("#standard-price>thead>tr").prepend(th);
                $("#standard-price>tbody>tr").prepend(td);
                if($("#standard-price tbody tr input[name=\"standard_price_name[]\"]").length==2)
                {
                    $("#add-standard-price").attr('class','layui-btn layui-btn-primary')
                }

            })


        });


        // 上架开始日期
        let insShelf = laydate.render({
            elem: '#start_time'
            , min: 0
            , calendar: true
            , type: 'datetime'
            , done: function (value, date) {
                //更新结束日期的最小日期
                insUnder.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                //insUnder.config.elem[0].focus();
            }
        });
        //上架结束日期
        let insUnder = laydate.render({
            elem: '#end_time'
            , min: 0
            , calendar: true
            , type: 'datetime'
            , done: function (value, date) {
                //更新开始日期的最大日期
                insShelf.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });
        //富文本


        let editor = new wangEditor('#LAY_demo_editor');
        editor.customConfig.uploadImgServer = "/admin/bizpro/Doupload";
        editor.customConfig.uploadFileName = 'image';
        editor.customConfig.pasteFilterStyle = false;
        editor.customConfig.uploadImgMaxLength = 5;
        editor.customConfig.uploadImgParams = {
            'mark': 'img',
            'field': 'image',
            'oldSrc': ''

        }
        editor.customConfig.uploadImgHooks = {
            before: function (xhr, editor, files) {
                // 图片上传之前触发
                // xhr 是 XMLHttpRequst 对象，editor 是编辑器对象，files 是选择的图片文件

                // 如果返回的结果是 {prevent: true, msg: 'xxxx'} 则表示用户放弃上传
                // return {
                //     prevent: true,
                //     msg: '放弃上传'
                // }
            },
            success: function (xhr, editor, result) {
                // 图片上传并返回结果，图片插入成功之后触发
                // xhr 是 XMLHttpRequst 对象，editor 是编辑器对象，result 是服务器端返回的结果
            },
            fail: function (xhr, editor, result) {
                // 图片上传并返回结果，但图片插入错误时触发
                // xhr 是 XMLHttpRequst 对象，editor 是编辑器对象，result 是服务器端返回的结果
            },
            error: function (xhr, editor) {
                // 图片上传出错时触发
                // xhr 是 XMLHttpRequst 对象，editor 是编辑器对象
            },
            timeout: function (xhr, editor) {
                // 图片上传超时时触发
                // xhr 是 XMLHttpRequst 对象，editor 是编辑器对象
            },

            // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
            // （但是，服务器端返回的必须是一个 JSON 格式字符串！！！否则会报错）
            customInsert: function (insertImg, result, editor) {
                // 图片上传并返回结果，自定义插入图片的事件（而不是编辑器自动插入图片！！！）
                // insertImg 是插入图片的函数，editor 是编辑器对象，result 是服务器端返回的结果
                // 举例：假如上传图片成功后，服务器端返回的是 {url:'....'} 这种格式，即可这样插入图片：
                let url = "{$Think.const.__MY_ROOT_PUBLIC__}"+"upload/"+result.src
                insertImg(url)
                // result 必须是一个 JSON 格式字符串！！！否则报错
                let urls=$("#editorimgurlHidden").val()+','+url

                $("#editorimgurlHidden").val(urls)
            }
        }
        editor.customConfig.customAlert = function (info) {
            layer.msg(info.msg);
        };
        editor.create();
        //初始化编辑器数据
        let info2 = "{$bizpro.detail}";
        let info3=$('<div>').html(info2).text()
        editor.txt.html(info3)
        // element.init();
        //轮播图多图片上传
        upload.render({
            elem: '#multiple_banner',
            url: '/admin/bizpro/Doupload',
            data: {
                'mark': 'img',
                'field': 'activeBanner',
                'oldSrc': ''
            },
            field: 'activeBanner',
            accept: 'images',
            acceptMime: 'image/*',
            multiple: true,
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {
                    $('#div-slide_show').append('<img src="' + result + '" alt="' + file.name +
                        '" title="点击删除" style="width: 100px;height: 100px" class="layui-upload-img" onclick="delMultipleImgs(this,\'banner\')">')
                });
            },
            done: function(res) {
                //如果上传成功
                if (res.status == true) {
                    //追加图片成功追加文件名至图片容器
                    banner_url.push(res.src);
                    $('#banner_images').val(banner_url);
                }
            },
            allDone: function(obj) {
                // console.log(obj.total); //得到总文件数
                // console.log(obj.successful); //请求成功的文件数
                // console.log(obj.aborted); //请求失败的文件数
            }
        });
        //单图片拖拽上传
        let uploadInst = upload.render({
            elem: '#headImg',
            url: '/admin/bizpro/Doupload',
            size: 500,
            field: 'thumb_img',
            accept: 'images',
            acceptMime: 'image/*',
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {
                    $('#imgurl').attr('src', result); //图片链接（base64）;
                });
                this.data = {
                    'mark': 'img',
                    'field': 'thumb_img',
                    'oldSrc': $("#imgurlHidden").val()
                };
            },
            done: function(res) {
                //如果上传失败
                if (res.status == false) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                // window.parent.uploadHeadImage(res.src);
                $("#imgurlHidden").val(res.src);
                let demoText = $('#demoText');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            },
            error: function() {
                //演示失败状态，并实现重传
                let demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function() {
                    uploadInst.upload();
                });
            },

        });
        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            if(this.checked){
                this.value=1;
            }else{
                this.value=2;
            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            data.field.detail=editor.txt.html();
            console.log(data.field)
            $.ajax({
                url: "/admin/bizpro/saveinfo?active=ajax",
                type: 'post',
                async: true,
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    if(res.status){
                        parent.layer.msg("操作成功!", {icon:1,time: 1000}, function () {
                            //重新加载父页面
                            parent.location.reload();
                        });
                        return;
                    }else{
                        layer.open({
                            title: '提示信息',
                            content: '<span style="color:red">'+res.code+':</span>'+res.msg
                        })
                        return false
                        // layer.msg(res.msg);
                    }

                },
                error: function(re) {

                    layer.open({
                        title: '提示信息',
                        // content: '<span style="color:red">'+re.responseJSON.errorCode+':</span>'+re.responseJSON.msg
                        content: '<span align="center" style="color:red">'+re.responseJSON.msg+'</span>'
                    })
                }
            });
            return false;
        });
    });
    /**
     * @context 卡券列表
     */
    let voucherOpen;
    function checkVoucher()
    {
        $.ajax({
            url: "/admin/Prize/getsPrizeVoucherList",
            type: 'post',
            async: true,
            data: {},
            dataType: 'json',
            success: function (res) {
                voucherOpen=layer.open({
                    type: 1 ,
                    title: "卡券列表",
                    area: ['800px', '500px'],
                    shade: 0.5,
                    maxmin: true,
                    content:res.data,
                    success:function(layero,index){
                        // 禁止回车键打开弹窗
                        $(":focus").blur();
                    }
                })
                return false;
            }
        });
    }
    /**
     * @context 选择卡券
     * @param id
     * @param title
     * @param price
     */
    function chooseVoucher(id,title,price)
    {
        $("#voucher_id").val(id);
        $("#voucher_title").val(title);
        $("#voucherShow").html(title+"    ￥"+price);
        layer.close(voucherOpen);
    }

    /**
     *
     * @context 删除图片
     * @param this_img
     * @param type
     */
    function delMultipleImgs(this_img, type) {
        //获取下标
        let subscript = $("#div-slide_show img").index(this_img);
        //删除图片
        this_img.remove();
        if (type == 'banner') {
            //删除轮播图数组
            banner_url.splice(subscript, 1);

            $('#banner_images').val(banner_url);
        } else {
            //删除详情图数组
            picurl_images.splice(subscript, 1);
            $('#picurl_images').val(picurl_images);
        }
        //返回
        return;
    }

    function standard(){
        layer.prompt({
            //2是 textarea 文本框 0 是input
            formType: 0,
            value: '',
            title: '请输入商品规格',
            // area: ['10px', '140px']
        },function(value, index){
            $.ajax({
                url: '/admin/bizpro/standard',
                type: 'post',
                dataType: 'json',
                data: {title:value},
                success: function (res) {
                    if (res.status == true) {
                        // 获得frame索引 赋值
                        $("#standard").html(res.str);
                        //关闭
                        // parent.reload();
                        layer.close(index)
                        //显示
                        $("#bizstandard").css('display', 'block');
                    }else{
                        layer.msg(res.msg,{ icon:5,
                            time: 1000});
                    }
                },
                error: function () {
                    layer.msg("报错了");
                }
            });



        });
    }
    function bizStandardDel(mark,value,id){

        layer.confirm('确定删除规格吗', function (index) {
            let proId = $("input[name='id']").val();
            $.ajax({
                url: "/admin/bizpro/bizStandardDel",
                type: 'post',
                async: true,
                data: {mark:mark,id:id},
                dataType: 'json',
                success: function (res) {
                    if (res.status == true) {
                        // 获得frame索引 赋值
                        // $("#standard").html(res.str);
                        //关闭
                        // parent.reload();
                        layer.close(index)
                        $.ajax({
                            url: '/admin/bizpro/standard',
                            type: 'post',
                            dataType: 'json',
                            data: {mark:mark,proId:proId},
                            success: function (res) {
                                if (res.status == true) {
                                    // 获得frame索引 赋值
                                    $("#standard").html(res.str);
                                    //关闭
                                    // parent.reload();
                                    layer.close(index)
                                    //显示
                                    $("#bizstandard").css('display', 'block');
                                }else{
                                    layer.msg(res.msg,{ icon:5,
                                        time: 1000});
                                }
                            },
                            error: function () {
                                layer.msg("报错了");
                            }
                        });
                        // standard()
                    }else{
                        layer.msg(res.msg,{ icon:5,
                            time: 1000});
                    }
                }
            });

        });
        //修改缓存中规格
        /*   layer.prompt({
               //2是 textarea 文本框 0 是input
               formType: 0,
               placeholder:'请输入新密码',
               val: '',
               title: '请修改商品规格',
               // area: ['10px', '140px']
           },function(val, index){
               // $('#layui-layer'+index + " .layui-layer-input").val(value);
               $.ajax({
                   url: '/admin/bizpro/bizStandardWrite',
                   type: 'post',
                   dataType: 'json',
                   data: {value:val,mark:mark,id:id},
                   success: function (res) {
                       if (res.status == true) {
                           // 获得frame索引 赋值
                           // $("#standard").html(res.str);
                           //关闭
                           // parent.reload();
                           layer.close(index)
                           $.ajax({
                               url: '/admin/bizpro/standard',
                               type: 'post',
                               dataType: 'json',
                               data: {},
                               success: function (res) {
                                   if (res.status == true) {
                                       // 获得frame索引 赋值
                                       $("#standard").html(res.str);
                                       //关闭
                                       // parent.reload();
                                       layer.close(index)
                                       //显示
                                       $("#bizstandard").css('display', 'block');
                                   }else{
                                       layer.msg(res.msg,{ icon:5,
                                           time: 1000});
                                   }
                               },
                               error: function () {
                                   layer.msg("报错了");
                               }
                           });
                           // standard()
                       }else{
                           layer.msg(res.msg,{ icon:5,
                               time: 1000});
                       }
                   },
                   error: function () {
                       layer.msg("报错了");
                   }
               });
           });*/


    }
    function getSessionDb(array){
        $.ajax({
            url: '/admin/bizpro/getSessionDb',
            type: 'post',
            dataType: 'json',
            data: {array:array,write:write},
            success: function (res) {
                if (res.status == true) {
                    // 获得frame索引 赋值
                    $("#standard").html(res.str);
                    //关闭
                    // parent.reload();
                    layer.close(index)
                    //显示
                    $("#bizstandard").css('display', 'block');
                }else{
                    layer.msg(res.msg,{ icon:5,
                        time: 1000});
                }
            },
            error: function () {
                layer.msg("报错了");
            }
        });
    }
    function deltr(obj) {
        $(obj).parent().parent().remove();
    }
</script>
</body>
</html>